<div class="divColorbox">
    <div class="divColorbox_Header">
        <span><i class="fa fa-star"></i><span>修改公会信息</span></span>
        <a class="Refresh"></a><a class="Close"></a>
    </div>
    <div class="divColorbox_Body row">
        <div>
            <input name="User_ID" type="hidden"/>
            <div class="row">
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">公会ID</span>
                        <input id="Family_ID" type="text" class="form-control" value="" disabled/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">昵称</span>
                        <input id="NickName" type="text" class="form-control" disabled/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">手机号</span>
                        <input id="Phone" type="text" class="form-control" disabled/>
                    </div>
                </div>
            </div>
            <div class="space-6"></div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">公会联系人</span>
                        <input id="ContactName" type="text" class="form-control"/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">QQ</span>
                        <input id="QQ" type="text" class="form-control" disabled/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">公会等级</span>
                        <input id="Level" type="text" class="form-control" disabled/>
                    </div>
                </div>
            </div>
            <div class="hr"></div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">身份证</span>
                        <input id="IDCard" type="text" class="form-control"/>
                        <span class="input-group-addon"><i class="fa fa-credit-card"></i></span>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">公会状态</span>
                        <input id="Family_Status" type="text" class="form-control" disabled/>
                        <span class="input-group-addon"><i class="fa fa-credit-card"></i></span>
                    </div>
                </div>
            </div>
            <div class="space-6"></div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">开户银行</span>
                        <select class="form-control" name="Account_BankName" id="Account_BankName">
                        </select>
                        <span class="input-group-addon"><i class="fa fa-university"></i></span>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">银行开户地及分行名</span>
                        <input id="Account_BankFullName" type="text" class="form-control"/>
                        <span class="input-group-addon"><i class="fa fa-university"></i></span>
                    </div>
                </div>
            </div>
            <div class="space-6"></div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">开户地（省）</span>
                        <select class="form-control" name="Account_Province" id="Account_Province">
                        </select>
                        <span class="input-group-addon"><i class="fa fa-university"></i></span>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">开户地（市）</span>
                        <select class="form-control" name="Account_City" id="Account_City">
                        </select>
                        <span class="input-group-addon"><i class="fa fa-university"></i></span>
                    </div>
                </div>
            </div>
            <div class="space-6"></div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon"> 开户姓名</span>
                        <input id="Account_RealName" type="text" class="form-control"/>
                        <span class="input-group-addon"><i class="fa fa-user"></i></span>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">开户帐号</span>
                        <input id="Account_CardNo" type="text" class="form-control"/>
                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                    </div>
                </div>
            </div>
            <div class="space-6"></div>
            <div class="row">
                <div class="col-sm-6">
                    <span class="input-group-addon">身份证正面</span>
                    <input type="file" id="exampleInputFileA">
                </div>
                <div class="col-sm-6">
                    <span class="input-group-addon">身份证反面</span>
                    <input type="file" id="exampleInputFileB">
                </div>
            </div>
        </div>
    </div>
    <div class="divColorbox_Footer">
        <button type="button" id="btnFreeze_Melt" class="btn btn-primary">
            <i class="fa fa-check"></i> <span id="J_Freeze_En"></span>
        </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" id="btnEdit_Alter" class="btn btn-primary">
            <i class="fa fa-check"></i> 修改
        </button>
        <button type="button" id="btnUndo"></button>
    </div>
</div>
<script src="<%- Virtual_Path.Static %>jquery.plugin/uploadifive/jquery.uploadifive.min.js"></script>
<link rel="stylesheet" href="<%- Virtual_Path.Static %>jquery.plugin/uploadifive/uploadifive.css">
<link rel="stylesheet" href="<%- Virtual_Path.Static %>jquery.plugin/uploadifive/uploadifive.custom.css">
<div id="UploadifiveQueue"></div>
<script>
    $(function () {
        if (_PageData.flag != 0) {
            $.KOC.Tips.Open("Error", _PageData.flag, {
                Timeout: 1000,
                onClose: function () {
                    parent.$.colorbox.close();
                }
            });
            return;
        }
        //////////////////////////////////////////////////////////
        //冻结解冻
        //////////////////////////////////////////////////////////
        $('#btnFreeze_Melt').on('click', function () {
            var params = {};
            params.Family_ID = $.trim($('#Family_ID').val());
            params.Family_Status = $.trim($('#Family_Status').val());
            if (params.Family_Status == '冻结') {
                params.StatusName='解冻';
                params.Status = 0;//解冻
            } else {
                params.StatusName='冻结';
                params.Status = 1;//冻结
            }
            if (!params.Family_ID) {
                $.KOC.Tips.Open('Error', '数据出错请刷新', {Timeout: 2000});
                return false;
            }
            $.KOC.Loading.Open();
            $.ajax({
                url: '/ajax/user.family-info.updatefamilystatus',
                type: 'post',
                dataType: 'json',
                data: {
                    Family_ID: params.Family_ID,
                    Status: params.Status
                },
                success: function (data) {
                    $.KOC.Loading.Close();
                    if (data.flag !== 0) {
                        $.KOC.Tips.Open("Error", data.msg + "(" + data.flag + ")", {Timeout: 2000});
                        return;
                    }
                    $.KOC.Tips.Open('Success',params.StatusName +'完成', {
                        Timeout: 1000,
                        onClose: function () {
                            parent.$.colorbox.close();
                            parent.window.location.href = "/user-manage/family-manage/familylist";
                        }
                    });
                }
            });
        });
        //////////////////////////////////////////////////////////
        //修改艺人信息
        //////////////////////////////////////////////////////////
        $('#btnEdit_Alter').click(function () {
            var params = {};
            var tel = /^0?(13[0-9]|15[012356789]|18[0123456789]|17[0123456789]|14[57])[0-9]{8}$|^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9]+\.[a-zA-Z0-9\.]+$/;
            var regIdCard = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
            params.Family_ID = $.trim($('#Family_ID').val());//User_ID
            params.ContactName = $.trim($('#ContactName').val());
            params.IDCard = $.trim($('#IDCard').val());//身份号
            params.Account_BankName = $('#Account_BankName').val();//银行
            params.Account_BankFullName = $.trim($('#Account_BankFullName').val());//分行地址及分行名
            params.Account_RealName = $.trim($('#Account_RealName').val());//开户姓名
            params.Account_CardNo = $.trim($('#Account_CardNo').val());//银行卡号
            params.Account_Province = $("#Account_Province option:selected").val();//省份
            params.Account_City = $("#Account_City option:selected").val();//市份
            if (!params.ContactName) {
                $.KOC.Tips.Open('Error', '公会联系人不能为空！', {Timeout: 1000});
            }
            if (!params.IDCard) {
                $.KOC.Tips.Open('Error', '身份证号不能为空！', {Timeout: 1000});
                $('#IDCard').focus();
                return false;
            } else if (!regIdCard.test(params.IDCard)) {
                $.KOC.Tips.Open('Error', '你输入的身份证号不正确', {Timeout: 1000});
                $('#IDCard').focus();
                return false;
            }
            if (!params.Account_BankFullName) {
                $.KOC.Tips.Open('Error', '分行地址及分行名不能为空！', {Timeout: 1000});
                $('#Account_BankFullName').focus();
                return false;
            }
            if (!params.Account_Province) {
                $.KOC.Tips.Open('Error', '请选择开户地省份！', {Timeout: 1000});
                $('#Account_Province').focus();
                return false;
            }
            if (!params.Account_City) {
                $.KOC.Tips.Open('Error', '请选择开户地市！', {Timeout: 1000});
                $('#Account_City').focus();
                return false;
            }
            if (!params.Account_RealName) {
                $.KOC.Tips.Open('Error', '开户行姓名不能为空！', {Timeout: 1000});
                $('#Account_RealName').focus();
                return false;
            }
            if (!params.Account_CardNo) {
                $.KOC.Tips.Open('Error', '银行卡号不能为空！', {Timeout: 1000});
                $('#Account_CardNo').focus();
                return false;
            }
            $.KOC.Loading.Open();
            $.ajax({
                url: '/ajax/user.family-info.update',
                type: 'post',
                dataType: 'json',
                data: {
                    User_ID: params.Family_ID,
                    ContactName: params.ContactName,
                    IDCard: params.IDCard,
                    Account_BankName: params.Account_BankName,
                    Account_BankFullName: params.Account_BankFullName,
                    Account_Province: params.Account_Province,
                    Account_City: params.Account_City,
                    Account_CardNo: params.Account_CardNo,
                    Account_RealName: params.Account_RealName
                },
                success: function (data) {
                    $.KOC.Loading.Close();
                    if (data.flag !== 0) {
                        $.KOC.Tips.Open("Error", data.msg + "(" + data.flag + ")", {Timeout: 2000});
                        return;
                    }
                    $.KOC.Tips.Open('Success', '修改完成', {
                        Timeout: 1000,
                        onClose: function () {
                            parent.$.colorbox.close();
                            parent.window.location.href = "/user-manage/family-manage/familylist";
                        }
                    });
                }
            });

        });
        ////////////////////////////////////
        //身份证上传
        ////////////////////////////////////
        $('#exampleInputFileA').uploadifive({
            'uploadScript': _VirtualPath.Utils + 'service/fileupload',
            'removeCompleted': true,
            'queueID': 'UploadifiveQueue',
            'multi': false,
            'buttonClass': '',
            'buttonText': '身份证(正面)',
            'fileType': 'image/*',
            'onUploadComplete': function (file, data) {
                data = $.parseJSON(data);
                if (data.flag !== 0) {
                    $.KOC.Tips.Open("Error", "上传文件出错，请重试！", {Timeout: 1000});
                    return;
                }
                $.ajax({
                    url: "/ajax/base.user-anchoridcard",
                    type: "post",
                    dataType: "json",
                    data: {
                        User_ID: _PageData.User_ID,
                        FileName: data.FileName,
                        Front: "a"
                    },
                    success: function (data) {
                        $.KOC.Tips.Open('Success', '身份证上传成功', {Timeout: 1000});
                    }
                });
            }
        });
        $('#exampleInputFileB').uploadifive({
            'uploadScript': _VirtualPath.Utils + 'service/fileupload',
            'removeCompleted': true,
            'queueID': 'UploadifiveQueue',
            'multi': false,
            'buttonClass': '',
            'buttonText': '身份证(背面)',
            'fileType': 'image/*',
            'onUploadComplete': function (file, data) {
                data = $.parseJSON(data);
                if (data.flag !== 0) {
                    $.KOC.Tips.Open("Error", "上传文件出错，请重试！", {Timeout: 1000});
                    return;
                }
                $.ajax({
                    url: "/ajax/base.user-anchoridcard",
                    type: "post",
                    dataType: "json",
                    data: {
                        User_ID: _PageData.User_ID,
                        FileName: data.FileName,
                        Front: "b"
                    },
                    success: function (data) {
                        $.KOC.Tips.Open('Success', '身份证上传成功', {Timeout: 1000});
                    }
                });
            }
        });
        //////////////////////////////////////////////////////////
        //银行标签
        //////////////////////////////////////////////////////////
        var Banks = '';
        for (var n = 0; n < _PageData.Banks.Data.length; n++) {
            if (_PageData.Banks.Data[n] == _PageData.Account_BankName) {
                Banks += '<option value="' + _PageData.Banks.Data[n] + '" selected>' + _PageData.Banks.Data[n] + '</option>';
            } else {
                Banks += '<option value="' + _PageData.Banks.Data[n] + '">' + _PageData.Banks.Data[n] + '</option>';
            }
        }
        $('#Account_BankName').empty().append(Banks);
        //////////////////////////////////////////////////////////
        //开户地(省)
        //////////////////////////////////////////////////////////
        var Province = '<option value="">--</option>';
        for (var n = 0; n < $.Common.GetProvince().length; n++) {
            if ($.Common.GetProvince()[n] == _PageData.Account_Province) {
                Province += '<option value="' + $.Common.GetProvince()[n] + '"  selected>' + $.Common.GetProvince()[n] + '</option>';
            } else {
                Province += '<option value="' + $.Common.GetProvince()[n] + '">' + $.Common.GetProvince()[n] + '</option>';
            }
        }
        $('#Account_Province').empty().append(Province);
        //////////////////////////////////////////////////////////
        //开户地(市)
        //////////////////////////////////////////////////////////
        var City = '<option value="">--</option>';
        if (_PageData.Account_Province) {
            for (var n = 0; n < $.Common.GetRegion(_PageData.Account_Province).length; n++) {
                if ($.Common.GetRegion(_PageData.Account_Province)[n] == _PageData.Account_City) {
                    City += '<option value="' + $.Common.GetRegion(_PageData.Account_Province)[n] + '"  selected>' + $.Common.GetRegion(_PageData.Account_Province)[n] + '</option>';
                } else {
                    City += '<option value="' + $.Common.GetRegion(_PageData.Account_Province)[n] + '">' + $.Common.GetRegion(_PageData.Account_Province)[n] + '</option>';
                }
            }
        }
        $('#Account_City').empty().append(City);
        //////////////////////////////////////////////////////////
        //切换省份，显示（市）
        //////////////////////////////////////////////////////////
        $("#Account_Province").change(function () {
            var region = {};
            region.Account_Province = $("#Account_Province option:selected").val();
            region.Account_City = $.Common.GetRegion(region.Account_Province);
            region.TageInfo += '<option value="" selected>--</option>';
            if (region.Account_City) {
                for (var i = 0; i < region.Account_City.length; i++) {
                    if (i == 0) {
                        region.TageInfo += '<option value="' + region.Account_City[i] + '">' + region.Account_City[i] + '</option>';
                    } else {
                        region.TageInfo += '<option value="' + region.Account_City[i] + '">' + region.Account_City[i] + '</option>';
                    }
                }
            }
            $('#Account_City').empty().append(region.TageInfo);
        });
        //////////////////////////////////////////////////////////
        //数据绑定
        //////////////////////////////////////////////////////////
        $('#J_Family_IdCard_A_Img').attr('src', _VirtualPath.Utils + "service/img/user/idcard-a/" + _PageData.User_ID + ".jpg");
        $('#J_Family_IdCard_B_Img').attr('src', _VirtualPath.Utils + "service/img/user/idcard-b/" + _PageData.User_ID + ".jpg");
        $('#Family_ID').val(_PageData.Family_ID);
        $('#NickName').val(_PageData.NickName);
        $('#Phone').val(_PageData.Phone);
        $('#QQ').val(_PageData.QQ);
        $('#Level').val(_PageData.Level.Level);
        $('#IDCard').val(_PageData.IDCard);
        $('#Account_BankFullName').val(_PageData.Account_BankFullName);
        $('#Account_RealName').val(_PageData.Account_RealName);
        $('#Account_CardNo').val(_PageData.Account_CardNo);
        $('#ContactName').val(_PageData.ContactName);

        switch (_PageData.Status) {
            case 0:
                $('#Family_Status').val('正常');
                $('#J_Freeze_En').text('冻结');
                break;
            case 1:
                $('#Family_Status').val('冻结');
                $('#J_Freeze_En').text('解冻');
                break;
            case 2:
                $('#Family_Status').val('申请');
                break;
            case 3:
                $('#Family_Status').val('拒绝');
                break;
            default:
                $('#Family_Status').val('--');
                break;
        }
        switch (_PageData.Sex) {
            case 1 :
                $("#Sex").val('男');
                break;
            case 2 :
                $("#Sex").val('女');
                break;
            default:
                $('#Sex').val('');
                break;
        }
    });
</script>